package com.topisv.tms.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.topisv.tms.entity.StoragePartition;
import com.topisv.tms.repository.StoragePartitionDao;

//Spring Bean的标识.
@Component
//默认将类中的所有public函数纳入事务管理.
@Transactional(readOnly = true)
public class StoragePartitionService {
	private StoragePartitionDao storagePartitionDao;
	
	@Autowired
	public void setStoragePartitionDao(StoragePartitionDao storagePartitionDao) {
		this.storagePartitionDao = storagePartitionDao;
	}

	public StoragePartition findByCode(String partition_code)
	{
		return storagePartitionDao.findByCode(partition_code);
	}
	
	public List<StoragePartition> findBySPCode(String storage_code)
	{
		return storagePartitionDao.findBySPCode(storage_code);
	}
	
	public StoragePartition getStoragePartition(Long id) {
		return storagePartitionDao.findOne(id);
	}
	
	@Transactional(readOnly = false)
	public void saveStoragePartition(StoragePartition entity) {
		storagePartitionDao.save(entity);
	}
	
	@Transactional(readOnly = false)
	public void deleteStoragePartition(Long id) {
		storagePartitionDao.delete(id);
	}
	
	public List<StoragePartition> getAllStoragePartition() {
		return (List<StoragePartition>) storagePartitionDao.findAll();
	}
	
}
